{include file="public/header" /}

<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-body layui-row layui-col-space10">
            共有数据：<strong id="count">{$list->total()}</strong> 条
          </div>
          <div class="layui-table-body layui-table-main">
            <table class="layui-table">
              <thead>
                <tr>
                  <th>
                    <div class="layui-table-cell">配置名</div>
                  </th>
                  <th>
                    <div class="layui-table-cell">参数</div>
                  </th>
                  <th>
                    <div class="layui-table-cell">操作</div>
                  </th>
                </tr>
              </thead>
              <tbody>
                {foreach $list as $v}
                <tr>
                  <td>
                    <div class="layui-table-cell">{$v.remark}</div>
                  </td>
                  <td>
                    {if $v.name == 'myus' || $v.name == 'mybank'}
                    <div class="layui-table-cell" style="color: red">
                      请编辑查看信息
                    </div>
                    {else}
                    <div class="layui-table-cell">{$v.value|default=''}</div>
                    {/if}
                  </td>
                  <td class="layui-table-col-special">
                    <div class="layui-table-cell">
                      <a
                        title="编辑"
                        onclick="open_add('编辑','/system/config_edit?name={$v.name}')"
                        href="javascript:;"
                        class="layui-btn layui-btn-sm"
                      >
                        编辑
                      </a>
                    </div>
                  </td>
                </tr>
                {/foreach}
              </tbody>
            </table>
          </div>
          <div class="layui-card-body">
            <div class="page">{$list->render()|raw}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
  {include file="public/footer"}
  <script>
    layui.use(["form", "layer"], function () {
      $ = layui.jquery;
      var form = layui.form,
        layer = layui.layer;
      //监听省份选择
      form.on("select(province)", function (data) {
        if (!data.value) {
          $('select[name="city"]').html("");
          $('select[name="area"]').html("");
          $('select[name="street"]').html("");
          form.render();
          return false;
        }
        //发异步，把数据提交给php
        $.ajax({
          type: "get",
          url: "/base/getregion",
          data: { area_code: data.value, level: 2 },
          success: function (res) {
            if (res.status == 0) {
              var str = '<option value="">请选择城市</option>';
              $.each(res.data, function (i, obj) {
                str += '<option value="' + obj.area_code;
                str += '">' + obj.name;
                str += "</option>";
              });
              $('select[name="city"]').html(str);
              $('select[name="area"]').html("");
              $('select[name="street"]').html("");
              form.render();
            } else {
              layer.msg(res.msg, { icon: 2, time: 1000 });
            }
          },
        });
        return false;
      });
      //监听城市选择
      form.on("select(city)", function (data) {
        if (!data.value) {
          $('select[name="area"]').html("");
          $('select[name="street"]').html("");
          form.render();
          return false;
        }
        //发异步，把数据提交给php
        $.ajax({
          type: "get",
          url: "/base/getregion",
          data: { area_code: data.value, level: 3 },
          success: function (res) {
            if (res.status == 0) {
              var str = '<option value="">请选择区域</option>';
              $.each(res.data, function (i, obj) {
                str += '<option value="' + obj.area_code;
                str += '">' + obj.name;
                str += "</option>";
              });
              $('select[name="area"]').html(str);
              $('select[name="street"]').html("");
              form.render();
            } else {
              layer.msg(res.msg, { icon: 2, time: 1000 });
            }
          },
        });
        return false;
      });
      //监听区域选择
      form.on("select(area)", function (data) {
        if (!data.value) {
          $('select[name="street"]').html("");
          form.render();
          return false;
        }
        //发异步，把数据提交给php
        $.ajax({
          type: "get",
          url: "/base/getregion",
          data: { area_code: data.value, level: 4 },
          success: function (res) {
            if (res.status == 0) {
              var str = '<option value="">请选择街道</option>';
              $.each(res.data, function (i, obj) {
                str += '<option value="' + obj.id;
                str += '">' + obj.name;
                str += "</option>";
              });
              $('select[name="street"]').html(str);
              form.render();
            } else {
              layer.msg(res.msg, { icon: 2, time: 1000 });
            }
          },
        });
        return false;
      });
    });
  </script>
</body>
